package org.example.web;


import com.example.fanqie.entity.Author;
import com.example.fanqie.entity.Category;
import com.example.fanqie.mapper.CategoryMapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/category")
public class categoryDao {


    @Resource
    private CategoryMapper categoryMapper;

    @RequestMapping("add")
    public int addCategory(@RequestBody Category category){
        int insert = categoryMapper.insert(category);

        return insert ;

    }

    @RequestMapping("select")
    public List<Category> selectauthor( ){

        List<Category> categories = categoryMapper.selectcategory();


        return categories;
    }

    @RequestMapping("delete")
    public int deletecategory( @RequestBody Category category){

        int delete = categoryMapper.updateById(category);

        return delete;
    }

}
